<html>
 <head>
  <link href="./leetcode-problem.css" rel="stylesheet" type="text/css">
 </head>
 <body>
  <div class="question_difficulty">
   难度：Medium
  </div>
  <div>
   <h1 class="question_title">
    33. Search in Rotated Sorted Array
   </h1>
   <p>
    Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
   </p>
   <p>
    (i.e.,
    <code>
     [0,1,2,4,5,6,7]
    </code>
    might become
    <code>
     [4,5,6,7,0,1,2]
    </code>
    ).
   </p>
   <p>
    You are given a target value to search. If found in the array return its index, otherwise return
    <code>
     -1
    </code>
    .
   </p>
   <p>
    You may assume no duplicate exists in the array.
   </p>
   <p>
    Your algorithm's runtime complexity must be in the order of&nbsp;
    <em>
     O
    </em>
    (log&nbsp;
    <em>
     n
    </em>
    ).
   </p>
   <p>
    <strong>
     Example 1:
    </strong>
   </p>
   <pre>
<strong>Input:</strong> nums = [<code>4,5,6,7,0,1,2]</code>, target = 0
<strong>Output:</strong> 4
</pre>
   <p>
    <strong>
     Example 2:
    </strong>
   </p>
   <pre>
<strong>Input:</strong> nums = [<code>4,5,6,7,0,1,2]</code>, target = 3
<strong>Output:</strong> -1</pre>
  </div>
  <div>
   <h1 class="question_title">
    33. 搜索旋转排序数组
   </h1>
   <p>
    假设按照升序排序的数组在预先未知的某个点上进行了旋转。
   </p>
   <p>
    ( 例如，数组&nbsp;
    <code>
     [0,1,2,4,5,6,7]
    </code>
    &nbsp;可能变为&nbsp;
    <code>
     [4,5,6,7,0,1,2]
    </code>
    &nbsp;)。
   </p>
   <p>
    搜索一个给定的目标值，如果数组中存在这个目标值，则返回它的索引，否则返回&nbsp;
    <code>
     -1
    </code>
    &nbsp;。
   </p>
   <p>
    你可以假设数组中不存在重复的元素。
   </p>
   <p>
    你的算法时间复杂度必须是&nbsp;
    <em>
     O
    </em>
    (log&nbsp;
    <em>
     n
    </em>
    ) 级别。
   </p>
   <p>
    <strong>
     示例 1:
    </strong>
   </p>
   <pre><strong>输入:</strong> nums = [<code>4,5,6,7,0,1,2]</code>, target = 0
<strong>输出:</strong> 4
</pre>
   <p>
    <strong>
     示例&nbsp;2:
    </strong>
   </p>
   <pre><strong>输入:</strong> nums = [<code>4,5,6,7,0,1,2]</code>, target = 3
<strong>输出:</strong> -1</pre>
  </div>
 </body>
</html>